#include<bits/stdc++.h>
using namespace std;
int a[100],t,n,ans;
int b[100];
void dfs(int deep,int cnt){
    if(deep==n+1)
    {
        ans=max(ans,cnt);
        return;
    }


    b[deep]=0;
    int i=deep-1;
    while(i>=1&&(b[i]!=b[deep]||a[i]!=a[deep]))i--;
    dfs(deep+1,cnt+a[i]);

    b[deep]=1;
    i=deep-1;
    while(i>=1&&(b[i]!=b[deep]||a[i]!=a[deep]))i--;
    dfs(deep+1,cnt+a[i]);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--)
    {
        cin>>n;
        memset(b,-1,sizeof(b));ans=0;
        for(int i=1;i<=n;i++)cin>>a[i];
        dfs(1,0);
        cout<<ans<<endl;
    }
    return 0;

}
